

#include "includes.h"

static void *
print(YJK_OBJECT arg)
{
  if (arg.tagged.tag == TAG_INT)
    {
      printf("%d\n", arg.fixnum.value);
    }
  else if (arg.tagged.tag == TAG_PTR)
    {
      //remove tag
      arg.tagged.tag = 0;

      switch (arg.object->type)
	{
	case TYPE_STRING:
	  printf("%s\n", arg.string->data);
	  break;
	  
	case TYPE_FLOAT:
	  printf("%f\n", arg.flt->value);
	  break;

	case TYPE_BIGINT:
	  print_bigint(arg.bigint);
	  break;

	case TYPE_RATIO:
	  print((YJK_OBJECT) arg.ratio->numerator);
	  printf("--------\n"); 
	  print((YJK_OBJECT) arg.ratio->denominator);
	  break;

	default:
	  printf("Reference: 0x%x\n", (int) arg.pointer);
	  break;
	};
      
      //replace tag
      arg.tagged.tag = TAG_PTR;
    }
  
  return 0x0;
}


void
main_print()
{
  push(print(get_arg(0)));
}

